package com.zryc.shop.sms.mapper;

import com.zryc.shop.sms.entity.FlashPromotionProductRelation;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 商品限时购与商品关系表 Mapper 接口
 * </p>
 *
 * @author LiYe
 * @since 2023-02-13
 */
public interface FlashPromotionProductRelationMapper extends BaseMapper<FlashPromotionProductRelation> {
    /**
     * 使用秒杀活动ID查询对应的商品关系列表
     * @param flashPromotionId
     * @return
     */
    @Select("SELECT R.id, S.name, S.start_time AS startTime, S.end_time AS endTime, R.flash_promotion_count AS productCount " +
            "FROM sms_flash_promotion_session S INNER JOIN sms_flash_promotion_product_relation R " +
            "ON S.id=R.flash_promotion_session_id AND R.flash_promotion_id=#{param1}")
    List<FlashPromotionProductRelation> selectListByFlashPromotionId(Long flashPromotionId);
}
